import Router from "./views/router";
import Home from "./views/home/index";
import { HashRouter } from "react-router-dom";
import store from "./views/store/store";
import { Provider } from 'react-redux'
import { useEffect } from "react";
function App() {
    let BL_start_time = 0;
    let timeGap = 0;// beforeunload和unload之间的时间差
    //两个标志监听浏览器是关闭还是刷新，分别对
    //beforeunload (窗口关闭或刷新前触发)
    //unload (窗口关闭或刷新后触发)
    // 刷新的window.onbeforeunload和window.onunload的时间差通常在10毫秒以上，而关闭的window.onbeforeunload和window.onunload的时间差通常在3毫秒以下
    window.addEventListener("beforeunload",() => {
        BL_start_time = new Date().getTime();
        console.log("执行了事件beforeunload");
        
    })
    window.addEventListener("unload",() => {
        timeGap = new Date().getTime() - BL_start_time;
        console.log("执行了事件unload");
        console.log(timeGap);
        if(timeGap >=7){
            // console.log("这是刷新!");
            // localStorage.setItem("132","上一次是刷新");
        }
        else{
            // console.log("这是关闭")
            // localStorage.setItem("132","上一次是关闭");
            localStorage.removeItem("logined");
        }
        
    })
    
    return (
        <HashRouter>
            {/* <Home /> */}
            <Provider store={store}>
                <Router />
            </Provider>
        </HashRouter>
    );
}

export default App;
